
#include <Windows.h>
#include <gl\GL.h>
#include <gl\GLU.h>
#include <gl\glut.h>
#include "CANVAS.H"


#include "object3d.h"
#include "vec3.h"
#include "model.h"

using namespace std;

class Rect2D : public Object3D
{
	public:
		Rect2D(float x, float y, float w, float h)
		{
			Vec3 top_left((float)x, (float)y);
			Vec3 top_right((float)x + w, (float)y);
			Vec3 bottom_right((float)x + w, (float)y + h);
			Vec3 bottom_left((float)x, (float)y + h);
			
			_coords.push_back(top_left);
			_coords.push_back(top_right);
			_coords.push_back(bottom_right);
			_coords.push_back(bottom_left);
			
			Vec3 color((float)1.0, (float)0.0, (float)0.0); // RED
			
			_colors.push_back(color);
			_colors.push_back(color);
			_colors.push_back(color);
			_colors.push_back(color);
			
			Vec3 normal((float)0, (float)0, (float)-1);
			
			_normals.push_back(normal);
			_normals.push_back(normal);
			_normals.push_back(normal);
			_normals.push_back(normal);
		}
};

class Square : public Model
{
	public:
		Square()
		{
			Rect2D rect(40, 40, 20, 20);
			addObject3D(rect);
		};
};

#define SCREEN_WIDTH 600
#define SCREEN_HEIGHT 600

void display(void);
void myMouse(int button, int state, int x, int y);
int clipSegment(Point2& p1, Point2& p2, RealRect W);

Canvas cvs(SCREEN_WIDTH, SCREEN_HEIGHT, "PointInPolly");
Square sq;

int main(int argc, char **argv)
{
	cvs.setBackgroundColor(1.0, 1.0, 1.0);
	cvs.setColor(0.0, 0.0, 0.0);
	cvs.setWindow(0, SCREEN_WIDTH, 0, SCREEN_HEIGHT);
	cvs.setViewport(0, SCREEN_WIDTH, 0, SCREEN_HEIGHT);
	glutDisplayFunc(display);
	glutMouseFunc(myMouse);
	glutIdleFunc(display);
	glutMainLoop();
}

void myMouse(int button, int state, int x, int y)
{
	
}

void display(void)
{
	cvs.clearScreen();

	sq.render();

	glFlush();
	glutSwapBuffers();
}